﻿using System.Collections.Generic;
using System.Linq;
using Model;

namespace ReportBrowser.ViewModel
{
    internal class MessageContainerModuleViewModel : ModuleViewModel
    {
        #region Lifecycle

        public MessageContainerModuleViewModel(Module model) : base(model) { }

        #endregion Lifecycle

        #region Properties

        public static bool IsCummulative { get; set; }

        public IEnumerable<MessageViewModel> Messages
        {
            get
            {
                return MessageViewModel.FindByModule(this.Model.AssemblyName, this.Model.Name, IsCummulative);
            }
        }

        public double Weight
        {
            get
            {
                return this.Messages.Sum(mvm => mvm.Weight);
            }
        }

        #endregion Properties

        #region Methods

        public static bool HasMessages(Module model)
        {
            return MessageViewModel.IsAnyByModule(model.AssemblyName, model.Name, IsCummulative);
        }

        #endregion Methods
    }
}
